
function [dfdt] = lax_wendroff(t,y)
global U  h  g  dx x Q dt;

dx1=1/dx;
dx2 = 1/(dx*dx);

% ---- Construct the spatial Discretization Matrix------%

a = U*dt/dx;
b1 = a/2*(a+1);
b0 = 1-a*a;
b2= a/2*(a-1);



A = zeros(x,x);
A(1,1) = b0;
A(1,2) =  b2;
A(1,x) = b1;

for k=2:x-1
    A(k,k) = b0;
    A(k,k+1) =  b2;
    A(k,k-1) =  b1;
end

A(x,x) = b0;
A(x,x-1)=b1;
A(x,1)   =  b2;

L=zeros(2*x,2*x);
L(x+1:2*x,x+1:2*x)=A;
L(1:x,1:x)=A;

L(1,2*x)   = h*dx2;
L(1,x+2)   = h*dx2;
L(x,x+1)   = h*dx2;
L(x,2*x-1) = h*dx2;
for k=1:x
    L(k,x+k)= -2*h*dx2;
    L(x+k,k)=g;
end

for k=2:x-1
    L(k,x+k-1) = h*dx2;
    L(k,x+k+1)= h*dx2;
end
%
Q =L;
dfdt = -L*y;
